﻿@model KL.Store.Web.Models.GuarantorsModel
@using KL.Store.Core
@{
    Layout = null;   
}
<br />
<div class="bg-info bs-bgb">
    <p>
        <i class="fa fa-info-circle"></i>&nbsp;Bu sayfada eklediğiniz kefilleri, senet ile alışveriş yaparken kullanabilirsiniz.
    </p>
</div>
<ul>
    @foreach (var item in Model.Guarantors)
    {
        <li class="guarantor-height col-xs-12 col-sm-12 col-md-4 col-lg-3">
            <div class="guarantor-height-inner">
                <b>@item.FirstName @item.LastName</b><br />

                @(Html.Raw(string.IsNullOrEmpty(item.CepTel) ? "" : item.CepTel + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.EvTel) ? "" : item.EvTel + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.EvAdres) ? "" : item.EvAdres + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.DogumYer) ? "" : item.DogumYer + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.DogumTarihi.ToString()) ? "" : item.DogumTarihi.ToString() + "<br />"))
                <br />
                <br />
                <div>
                    <a class="btn btn-custom1 guarantorEdit" onclick="updateGuarantor(@item.AccountId)" href="#guarantor-update">Düzenle</a>
                    <a class="btn btn-custom1" onclick="deleteGuarantor(@item.AccountId)">Sil</a>
                </div>
            </div>
        </li>
    }
</ul>
<div class="clearfix"></div>
<br />
<div class="col-sm-12">
    <a class="btn btn-custom1 guarantorEdit" onclick="updateGuarantor(0)" href="#guarantor-update">Yeni Kefil Ekle</a>
</div>
@if (Parameters.Theme == "JJ")
{
    <script>
        $(document).ready(function ()
        {
            if ($(window).width() < 980)
            {
                $(".breadcrumb").parent().attr("class", $(".breadcrumb").parent().attr("class") + " first last");
            }
        });
    </script>
}
<script type="text/javascript">
    function updateGuarantor(id)
    {
        //$("#dialog-form").load("/Address/Update", { Id2: id });
        //$("#dialog-form").dialog("open");
        $("#guarantor-update").load("/Account/UpdateGuarantor", { Id2: id });
    }
    function deleteGuarantor(id)
    {
        var answer = confirm("Kefil silinecektir.  Devam edilsin mi?")
        if (answer)
        {
            $('#GuarantorList').load('/Account/DeleteGuarantor', { id: id });
        }
        return false;
    }
    $(document).ready(function ()
    {
        var lBoxWidth = 750;
        if ($(window).width() < 525)
        {
            var lBoxWidth = '100%';
        }
        $(".guarantorEdit").fancybox({
            width: lBoxWidth,
            fitToView: true,
            autoSize: false,
            autoDimensions: false,
            autoScale: true,
            afterClose: function ()
            {
                $('#GuarantorList').load('/Account/GuarantorsGet');
                $('#guarantor-update').html('');
            }
        });

        var enYuksekKefil = 0;
        $("#GuarantorList ul li").each(function ()
        {
            if ($(this).height() > enYuksekKefil)
            {
                enYuksekKefil = $(this).height();
            }
        });
        $("#GuarantorList ul li").height(enYuksekKefil + 3);
        $("#GuarantorList ul li .guarantor-height-inner").height(enYuksekKefil);
    });
</script>
